package com.heima.behavior.controller;

import com.heima.apis.behavior.ApBehaviorControllerApi;
import com.heima.behavior.service.ApBehaviorService;
import com.heima.model.behavior.pojo.ApBehaviorEntry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/behavior")
public class ApBehaviorController implements ApBehaviorControllerApi {

    @Autowired
    ApBehaviorService apBehaviorService;
    @GetMapping("/findOne/{userId}/{equipmentId}")
    @Override
    public ApBehaviorEntry findByUserIdOrEquipmentId(@PathVariable("userId") Integer userId,@PathVariable("equipmentId") Integer equipmentId) {

        return apBehaviorService.findByUserIdOrEquipmentId(userId,equipmentId);
    }

    /**
     * 根据用户id查询实体对象
     * @param userId
     * @return
     */
    @GetMapping("/findByUserId/{userId}")
    @Override
    public ApBehaviorEntry findByUserId(@PathVariable("userId") Integer userId) {

        return apBehaviorService.findByUserId(userId);
    }
}
